﻿using hou_elearning.DataAccess.Base;
using hou_elearning.Entity;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Collections;
using System.Web;

/// <summary>
/// Summary description for CustomBRL
/// </summary>
/// 
namespace hou_elearning.Custom
{
    public class QuyenCustomBRL : SqlProvider<QuyenEntity>
    {
        public QuyenCustomBRL()
        {
            
        }

        protected static void InitReader()
        {
            getFromReader = delegate(SqlDataReader dr)
            {
                QuyenEntity entity = new QuyenEntity();
                entity.PK_iQuyenID = Int16.Parse("0" + dr["PK_iQuyenID"].ToString());
                entity.sTenquyen = dr["sTenquyen"].ToString();
                entity.sTenviettat = dr["sTenviettat"].ToString();
                entity.sGhichu = dr["sGhichu"].ToString();
                return entity;
            };
        }

        public static bool bCheckDupByTenviettat(String sTenviettat)
        {
            string cmdName = "spQuyen_GetByShortName";
            SqlParameter p = new SqlParameter("@sTenviettat", sTenviettat);
            QuyenEntity entity = GetOne(cmdName, p);
            if (entity != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public static bool bCheckDupByTenquyen(String sTenquyen)
        {
            string cmdName = "spQuyen_GetByName";
            SqlParameter p = new SqlParameter("@sTenquyen", sTenquyen);
            QuyenEntity entity = GetOne(cmdName, p);
            if (entity != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}